/**
 * 
 */
package infomanager;

import info.Room;

/**
 * @author vtkhanh
 * 
 */
public class RoomManager {
    private static Room[] sRooms;
    private static int sRoomNum = 0;
    private static int sCount = 0;

    public static Room[] getRooms() {
	if (sRooms == null) {
	    sRooms = new Room[sRoomNum];
	}
	return sRooms;
    }
    
    public static Room getRoomById(int id) {
	for (Room room : sRooms) {
	    if (room.getRoomId() == id) {
		return room;
	    }
	}
	return null;
    }
    
    public static void addRoom(Room room) {
	if (sCount < sRoomNum) {
	    sRooms[sCount] = room;
	    sCount++;
	}
    }

    public static void setRooms(Room[] sRooms) {
	RoomManager.sRooms = sRooms;
    }
    
    public static void setNumberOfRooms(int num) {
	sRoomNum = num;
    }
    
    public static int getNumberOfRooms() {
	return sRoomNum;
    }
}
